home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / drivers / shuuz.c < prev    next >
C/C++ Source or Header  |  2000-04-04  |  12KB  |  439 lines

  1. /***************************************************************************
  2.  
  3.     Shuuz
  4.  
  5.     driver by Aaron Giles
  6.  
  7. ****************************************************************************/
  8.  
  9.  
  10. #include "driver.h"
  11. #include "machine/atarigen.h"
  12. #include "vidhrdw/generic.h"
  13.  
  14.  
  15. WRITE_HANDLER( shuuz_playfieldram_w );
  16.  
  17. int shuuz_vh_start(void);
  18. void shuuz_vh_stop(void);
  19. void shuuz_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh);
  20.  
  21. void shuuz_scanline_update(int scanline);
  22.  
  23.  
  24.  
  25. /*************************************
  26.  *
  27.  *    Interrupt handling
  28.  *
  29.  *************************************/
  30.  
  31. static void update_interrupts(void)
  32. {
  33.     int newstate = 0;
  34.  
  35.     if (atarigen_scanline_int_state)
  36.         newstate = 4;
  37.  
  38.     if (newstate)
  39.         cpu_set_irq_line(0, newstate, ASSERT_LINE);
  40.     else
  41.         cpu_set_irq_line(0, 7, CLEAR_LINE);
  42. }
  43.  
  44.  
  45.  
  46. /*************************************
  47.  *
  48.  *    Initialization
  49.  *
  50.  *************************************/
  51.  
  52. static void init_machine(void)
  53. {
  54.     atarigen_eeprom_reset();
  55.     atarigen_video_control_reset();
  56.     atarigen_interrupt_reset(update_interrupts);
  57.     atarigen_scanline_timer_reset(shuuz_scanline_update, 8);
  58. }
  59.  
  60.  
  61. static WRITE_HANDLER( latch_w )
  62. {
  63.     (void)offset;
  64.     (void)data;
  65. }
  66.  
  67.  
  68.  
  69. /*************************************
  70.  *
  71.  *    LETA I/O
  72.  *
  73.  *************************************/
  74.  
  75. static READ_HANDLER( leta_r )
  76. {
  77.     /* trackball -- rotated 45 degrees? */
  78.     static int cur[2];
  79.     int which = (offset >> 1) & 1;
  80.  
  81.     /* when reading the even ports, do a real analog port update */
  82.     if (which == 0)
  83.     {
  84.         int dx = (INT8)input_port_2_r(offset);
  85.         int dy = (INT8)input_port_3_r(offset);
  86.  
  87.         cur[0] = dx + dy;
  88.         cur[1] = dx - dy;
  89.     }
  90.  
  91.     /* clip the result to -0x3f to +0x3f to remove directional ambiguities */
  92.     return cur[which];
  93. }
  94.  
  95.  
  96.  
  97. /*************************************
  98.  *
  99.  *    MSM5295 I/O
  100.  *
  101.  *************************************/
  102.  
  103. static READ_HANDLER( adpcm_r )
  104. {
  105.     return OKIM6295_status_0_r(offset) | 0xff00;
  106. }
  107.  
  108.  
  109. static WRITE_HANDLER( adpcm_w )
  110. {
  111.     if (!(data & 0x00ff0000))
  112.         OKIM6295_data_0_w(offset, data & 0xff);
  113. }
  114.  
  115.  
  116.  
  117. /*************************************
  118.  *
  119.  *    Additional I/O
  120.  *
  121.  *************************************/
  122.  
  123. static READ_HANDLER( special_port0_r )
  124. {
  125.     int result = input_port_0_r(offset);
  126.  
  127.     if ((result & 0x0800) && atarigen_get_hblank())
  128.         result &= ~0x0800;
  129.  
  130.     return result;
  131. }
  132.  
  133.  
  134.  
  135. /*************************************
  136.  *
  137.  *    Main CPU memory handlers
  138.  *
  139.  *************************************/
  140.  
  141. static struct MemoryReadAddress readmem[] =
  142. {
  143.     { 0x000000, 0x03ffff, MRA_ROM },
  144.     { 0x100000, 0x100fff, atarigen_eeprom_r },
  145.     { 0x103000, 0x103003, leta_r },
  146.     { 0x105000, 0x105001, special_port0_r },
  147.     { 0x105002, 0x105003, input_port_1_r },
  148.     { 0x106000, 0x106001, adpcm_r },
  149.     { 0x107000, 0x107007, MRA_NOP },
  150.     { 0x3e0000, 0x3e087f, MRA_BANK1 },
  151.     { 0x3effc0, 0x3effff, atarigen_video_control_r },
  152.     { 0x3f4000, 0x3f7fff, MRA_BANK2 },
  153.     { 0x3f8000, 0x3fcfff, MRA_BANK3 },
  154.     { 0x3fd000, 0x3fd3ff, MRA_BANK4 },
  155.     { 0x3fd400, 0x3fffff, MRA_BANK5 },
  156.     { -1 }  /* end of table */
  157. };
  158.  
  159.  
  160. static struct MemoryWriteAddress writemem[] =
  161. {
  162.     { 0x000000, 0x03ffff, MWA_ROM },
  163.     { 0x100000, 0x100fff, atarigen_eeprom_w, &atarigen_eeprom, &atarigen_eeprom_size },
  164.     { 0x101000, 0x101fff, atarigen_eeprom_enable_w },
  165.     { 0x102000, 0x102001, watchdog_reset_w },
  166.     { 0x105000, 0x105001, latch_w },
  167.     { 0x106000, 0x106001, adpcm_w },
  168.     { 0x107000, 0x107007, MWA_NOP },
  169.     { 0x3e0000, 0x3e087f, atarigen_666_paletteram_w, &paletteram },
  170.     { 0x3effc0, 0x3effff, atarigen_video_control_w, &atarigen_video_control_data },
  171.     { 0x3f4000, 0x3f7fff, shuuz_playfieldram_w, &atarigen_playfieldram, &atarigen_playfieldram_size },
  172.     { 0x3f8000, 0x3fcfff, MWA_BANK3 },
  173.     { 0x3fd000, 0x3fd3ff, MWA_BANK4, &atarigen_spriteram },
  174.     { 0x3fd400, 0x3fffff, MWA_BANK5 },
  175.     { -1 }  /* end of table */
  176. };
  177.  
  178.  
  179.  
  180. /*************************************
  181.  *
  182.  *    Port definitions
  183.  *
  184.  *************************************/
  185.  
  186. INPUT_PORTS_START( shuuz )
  187.     PORT_START
  188.     PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_COIN1 )
  189.     PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_COIN2 )
  190.     PORT_BIT( 0x07fc, IP_ACTIVE_LOW, IPT_UNUSED )
  191.     PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_VBLANK )
  192.     PORT_BIT( 0xf000, IP_ACTIVE_LOW, IPT_UNUSED )
  193.  
  194.     PORT_START
  195.     PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER1 )
  196.     PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER1 )
  197.     PORT_BIT( 0x07fc, IP_ACTIVE_LOW, IPT_UNUSED )
  198.     PORT_SERVICE( 0x0800, IP_ACTIVE_LOW )
  199.     PORT_BIT( 0xf000, IP_ACTIVE_LOW, IPT_UNUSED )
  200.  
  201.     PORT_START
  202.     PORT_ANALOG( 0xff, 0, IPT_TRACKBALL_X | IPF_PLAYER1, 50, 30, 0, 0 )
  203.     PORT_BIT( 0xff00, IP_ACTIVE_LOW, IPT_UNUSED )
  204.  
  205.     PORT_START
  206.     PORT_ANALOG( 0xff, 0, IPT_TRACKBALL_Y | IPF_REVERSE | IPF_PLAYER1, 50, 30, 0, 0 )
  207.     PORT_BIT( 0xff00, IP_ACTIVE_LOW, IPT_UNUSED )
  208. INPUT_PORTS_END
  209.  
  210.  
  211. INPUT_PORTS_START( shuuz2 )
  212.     PORT_START
  213.     PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_COIN1 )
  214.     PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_COIN2 )
  215.     PORT_BIT( 0x00fc, IP_ACTIVE_LOW, IPT_UNUSED )
  216.     PORT_BITX(  0x0100, IP_ACTIVE_LOW, 0, "Step Debug SW", KEYCODE_S, IP_JOY_NONE )
  217.     PORT_BIT( 0x0600, IP_ACTIVE_LOW, IPT_UNUSED )
  218.     PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_VBLANK )
  219.     PORT_BITX(  0x1000, IP_ACTIVE_LOW, 0, "Playfield Debug SW", KEYCODE_Y, IP_JOY_NONE )
  220.     PORT_BITX(  0x2000, IP_ACTIVE_LOW, 0, "Reset Debug SW", KEYCODE_E, IP_JOY_NONE )
  221.     PORT_BITX(  0x4000, IP_ACTIVE_LOW, 0, "Crosshair Debug SW", KEYCODE_C, IP_JOY_NONE )
  222.     PORT_BITX(  0x8000, IP_ACTIVE_LOW, 0, "Freeze Debug SW", KEYCODE_F, IP_JOY_NONE )
  223.  
  224.     PORT_START
  225.     PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER1 )
  226.     PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER1 )
  227.     PORT_BIT( 0x00fc, IP_ACTIVE_LOW, IPT_UNUSED )
  228.     PORT_BITX(  0x0100, IP_ACTIVE_LOW, 0, "Replay Debug SW", KEYCODE_R, IP_JOY_NONE )
  229.     PORT_BIT( 0x0600, IP_ACTIVE_LOW, IPT_UNUSED )
  230.     PORT_SERVICE( 0x0800, IP_ACTIVE_LOW )
  231.     PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_PLAYER1 )
  232.     PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_PLAYER1 )
  233.     PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_PLAYER1 )
  234.     PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_PLAYER1 )
  235.  
  236.     PORT_START
  237.     PORT_ANALOG( 0xff, 0, IPT_TRACKBALL_X | IPF_PLAYER1, 50, 30, 0, 0 )
  238.     PORT_BIT( 0xff00, IP_ACTIVE_LOW, IPT_UNUSED )
  239.  
  240.     PORT_START
  241.     PORT_ANALOG( 0xff, 0, IPT_TRACKBALL_Y | IPF_REVERSE | IPF_PLAYER1, 50, 30, 0, 0 )
  242.     PORT_BIT( 0xff00, IP_ACTIVE_LOW, IPT_UNUSED )
  243. INPUT_PORTS_END
  244.  
  245.  
  246.  
  247. /*************************************
  248.  *
  249.  *    Graphics definitions
  250.  *
  251.  *************************************/
  252.  
  253. static struct GfxLayout pflayout =
  254. {
  255.     8,8,    /* 8*8 sprites */
  256.     16384,    /* 16384 of them */
  257.     4,        /* 4 bits per pixel */
  258.     { 0, 4, 0+0x40000*8, 4+0x40000*8 },
  259.     { 0, 1, 2, 3, 8, 9, 10, 11 },
  260.     { 0*8, 2*8, 4*8, 6*8, 8*8, 10*8, 12*8, 14*8 },
  261.     16*8    /* every sprite takes 16 consecutive bytes */
  262. };
  263.  
  264.  
  265. static struct GfxLayout molayout =
  266. {
  267.     8,8,    /* 8*8 sprites */
  268.     32768,    /* 32768 of them */
  269.     4,        /* 4 bits per pixel */
  270.     { 0, 4, 0+0x80000*8, 4+0x80000*8 },
  271.     { 0, 1, 2, 3, 8, 9, 10, 11 },
  272.     { 0*8, 2*8, 4*8, 6*8, 8*8, 10*8, 12*8, 14*8 },
  273.     16*8    /* every sprite takes 16 consecutive bytes */
  274. };
  275.  
  276.  
  277. static struct GfxDecodeInfo gfxdecodeinfo[] =
  278. {
  279.     { REGION_GFX1, 0, &pflayout,  256, 16 },        /* sprites & playfield */
  280.     { REGION_GFX2, 0, &molayout,    0, 16 },        /* sprites & playfield */
  281.     { -1 } /* end of array */
  282. };
  283.  
  284.  
  285.  
  286. /*************************************
  287.  *
  288.  *    Sound definitions
  289.  *
  290.  *************************************/
  291.  
  292. static struct OKIM6295interface okim6295_interface =
  293. {
  294.     1,                    /* 1 chip */
  295.     { ATARI_CLOCK_14MHz/16/132 },
  296.     { REGION_SOUND1 },
  297.     { 100 }
  298. };
  299.  
  300.  
  301.  
  302. /*************************************
  303.  *
  304.  *    Machine driver
  305.  *
  306.  *************************************/
  307.  
  308. static struct MachineDriver machine_driver_shuuz =
  309. {
  310.     /* basic machine hardware */
  311.     {
  312.         {
  313.             CPU_M68000,        /* verified */
  314.             ATARI_CLOCK_14MHz/2,
  315.             readmem,writemem,0,0,
  316.             ignore_interrupt,1
  317.         }
  318.     },
  319.     60, DEFAULT_REAL_60HZ_VBLANK_DURATION,    /* frames per second, vblank duration */
  320.     1,
  321.     init_machine,
  322.  
  323.     /* video hardware */
  324.     42*8, 30*8, { 0*8, 42*8-1, 0*8, 30*8-1 },
  325.     gfxdecodeinfo,
  326.     1024, 1024,
  327.     0,
  328.  
  329.     VIDEO_TYPE_RASTER | VIDEO_MODIFIES_PALETTE | VIDEO_UPDATE_BEFORE_VBLANK | VIDEO_SUPPORTS_DIRTY,
  330.     0,
  331.     shuuz_vh_start,
  332.     shuuz_vh_stop,
  333.     shuuz_vh_screenrefresh,
  334.  
  335.     /* sound hardware */
  336.     0,0,0,0,
  337.     {
  338.         {
  339.             SOUND_OKIM6295,
  340.             &okim6295_interface
  341.         }
  342.     },
  343.  
  344.     atarigen_nvram_handler
  345. };
  346.  
  347.  
  348.  
  349. /*************************************
  350.  *
  351.  *    ROM decoding
  352.  *
  353.  *************************************/
  354.  
  355. static void rom_decode(void)
  356. {
  357.     int i;
  358.  
  359.     for (i = 0; i < memory_region_length(REGION_GFX1); i++)
  360.         memory_region(REGION_GFX1)[i] ^= 0xff;
  361.     for (i = 0; i < memory_region_length(REGION_GFX2); i++)
  362.         memory_region(REGION_GFX2)[i] ^= 0xff;
  363. }
  364.  
  365.  
  366.  
  367. /*************************************
  368.  *
  369.  *    ROM definition(s)
  370.  *
  371.  *************************************/
  372.  
  373. ROM_START( shuuz )
  374.     ROM_REGION( 0x40000, REGION_CPU1 )    /* 4*64k for 68000 code */
  375.     ROM_LOAD_EVEN( "4010.23p",     0x00000, 0x20000, 0x1c2459f8 )
  376.     ROM_LOAD_ODD ( "4011.13p",     0x00000, 0x20000, 0x6db53a85 )
  377.  
  378.     ROM_REGION( 0x080000, REGION_GFX1 | REGIONFLAG_DISPOSE )
  379.     ROM_LOAD( "2030.43x", 0x000000, 0x20000, 0x8ecf1ed8 )
  380.     ROM_LOAD( "2032.20x", 0x020000, 0x20000, 0x5af184e6 )
  381.     ROM_LOAD( "2031.87x", 0x040000, 0x20000, 0x72e9db63 )
  382.     ROM_LOAD( "2033.65x", 0x060000, 0x20000, 0x8f552498 )
  383.  
  384.     ROM_REGION( 0x100000, REGION_GFX2 | REGIONFLAG_DISPOSE )
  385.     ROM_LOAD( "1020.43u", 0x000000, 0x20000, 0xd21ad039 )
  386.     ROM_LOAD( "1022.20u", 0x020000, 0x20000, 0x0c10bc90 )
  387.     ROM_LOAD( "1024.43m", 0x040000, 0x20000, 0xadb09347 )
  388.     ROM_LOAD( "1026.20m", 0x060000, 0x20000, 0x9b20e13d )
  389.     ROM_LOAD( "1021.87u", 0x080000, 0x20000, 0x8388910c )
  390.     ROM_LOAD( "1023.65u", 0x0a0000, 0x20000, 0x71353112 )
  391.     ROM_LOAD( "1025.87m", 0x0c0000, 0x20000, 0xf7b20a64 )
  392.     ROM_LOAD( "1027.65m", 0x0e0000, 0x20000, 0x55d54952 )
  393.  
  394.     ROM_REGION( 0x40000, REGION_SOUND1 )    /* ADPCM data */
  395.     ROM_LOAD( "1040.75b", 0x00000, 0x20000, 0x0896702b )
  396.     ROM_LOAD( "1041.65b", 0x20000, 0x20000, 0xb3b07ce9 )
  397. ROM_END
  398.  
  399.  
  400. ROM_START( shuuz2 )
  401.     ROM_REGION( 0x40000, REGION_CPU1 )    /* 4*64k for 68000 code */
  402.     ROM_LOAD_EVEN( "23p.rom",     0x00000, 0x20000, 0x98aec4e7 )
  403.     ROM_LOAD_ODD ( "13p.rom",     0x00000, 0x20000, 0xdd9d5d5c )
  404.  
  405.     ROM_REGION( 0x080000, REGION_GFX1 | REGIONFLAG_DISPOSE )
  406.     ROM_LOAD( "2030.43x", 0x000000, 0x20000, 0x8ecf1ed8 )
  407.     ROM_LOAD( "2032.20x", 0x020000, 0x20000, 0x5af184e6 )
  408.     ROM_LOAD( "2031.87x", 0x040000, 0x20000, 0x72e9db63 )
  409.     ROM_LOAD( "2033.65x", 0x060000, 0x20000, 0x8f552498 )
  410.  
  411.     ROM_REGION( 0x100000, REGION_GFX2 | REGIONFLAG_DISPOSE )
  412.     ROM_LOAD( "1020.43u", 0x000000, 0x20000, 0xd21ad039 )
  413.     ROM_LOAD( "1022.20u", 0x020000, 0x20000, 0x0c10bc90 )
  414.     ROM_LOAD( "1024.43m", 0x040000, 0x20000, 0xadb09347 )
  415.     ROM_LOAD( "1026.20m", 0x060000, 0x20000, 0x9b20e13d )
  416.     ROM_LOAD( "1021.87u", 0x080000, 0x20000, 0x8388910c )
  417.     ROM_LOAD( "1023.65u", 0x0a0000, 0x20000, 0x71353112 )
  418.     ROM_LOAD( "1025.87m", 0x0c0000, 0x20000, 0xf7b20a64 )
  419.     ROM_LOAD( "1027.65m", 0x0e0000, 0x20000, 0x55d54952 )
  420.  
  421.     ROM_REGION( 0x40000, REGION_SOUND1 )    /* ADPCM data */
  422.     ROM_LOAD( "1040.75b", 0x00000, 0x20000, 0x0896702b )
  423.     ROM_LOAD( "1041.65b", 0x20000, 0x20000, 0xb3b07ce9 )
  424. ROM_END
  425.  
  426.  
  427.  
  428. static void init_shuuz(void)
  429. {
  430.     atarigen_eeprom_default = NULL;
  431.  
  432.     rom_decode();
  433. }
  434.  
  435.  
  436.  
  437. GAME( 1990, shuuz,  0,     shuuz, shuuz,  shuuz, ROT0, "Atari Games", "Shuuz (version 8.0)" )
  438. GAME( 1990, shuuz2, shuuz, shuuz, shuuz2, shuuz, ROT0, "Atari Games", "Shuuz (version 7.1)" )
  439.